﻿<UserControl x:Class="SeismoUserControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:vc="clr-namespace:Visifire.Charts;assembly=WPFVisifire.Charts"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="303" d:DesignHeight="392.965">

	<Grid x:Name="grid" VerticalAlignment="Stretch" Width="Auto" Height="Auto">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="1*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="1*"/>
		</Grid.ColumnDefinitions>
		<StackPanel Orientation="Vertical" Margin="5">
			<Label Content="Sensor:" FontWeight="bold"/>
			<TextBlock Margin="10,0,10,0" Text="{Binding SensorName}" />
			<Label Content="Last reading:" FontWeight="bold"/>
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width=".1*" />
					<ColumnDefinition Width=".2*" />
					<ColumnDefinition Width=".1*" />
					<ColumnDefinition Width=".2*" />
					<ColumnDefinition Width=".1*" />
					<ColumnDefinition Width=".2*" />
				</Grid.ColumnDefinitions>
				<Label Content="X:" FontWeight="bold"/>
				<TextBlock Grid.Column="1" Margin="10,0,10,0" Text="{Binding LastDataReportX}" />
				<Label Grid.Column="2" Content="Y:" FontWeight="bold"/>
				<TextBlock Grid.Column="3" Margin="10,0,10,0" Text="{Binding LastDataReportY}" />
				<Label Grid.Column="4" Content="Z:" FontWeight="bold"/>
				<TextBlock Grid.Column="5" Margin="10,0,10,0" Text="{Binding LastDataReportZ}" />
			</Grid>
			<Label Content="Magnitude:" FontWeight="bold"/>
			<TextBlock Margin="10,0,10,0" Text="{Binding Magnitude}" />
			<Label Content="Sensitivity (1-3):" FontWeight="bold"/>
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width=".75*" />
					<ColumnDefinition Width=".25*" />
				</Grid.ColumnDefinitions>
				<Slider x:Name="slider" Margin="10,0,10,0" Value="{Binding Sensitivity, Mode=TwoWay}" Minimum="0" Maximum="3"  />
				<Label Content="{Binding Value, ElementName=slider}" FontWeight="bold" Grid.Column="1"/>
			</Grid>
		</StackPanel>
		<vc:Chart Grid.Row="1" ScrollingEnabled="True">
			<vc:Chart.Titles>
				<vc:Title Text="Sensor Readings" />
			</vc:Chart.Titles>
			<vc:Chart.AxesY>
				<vc:Axis Title="G's" />
			</vc:Chart.AxesY>
			<vc:Chart.AxesX>
				<vc:Axis ScrollBarOffset="1" Interval="5" IntervalType="Seconds" ValueFormatString="H:mm:ss" />
			</vc:Chart.AxesX>
			<vc:Chart.Series>
				<vc:DataSeries ToolTipText="#AxisXLabel, Y = #YValue" RenderAs="Line" XValueType="DateTime" LegendText="X" DataSource="{Binding ReadingsX}">
					<vc:DataSeries.DataMappings>
						<vc:DataMapping MemberName="XValue" Path="Timestamp"></vc:DataMapping>
						<vc:DataMapping MemberName="YValue" Path="Reading"></vc:DataMapping>
					</vc:DataSeries.DataMappings>
				</vc:DataSeries>
				<vc:DataSeries ToolTipText="#AxisXLabel, Y = #YValue" RenderAs="Line" XValueType="DateTime" LegendText="Y" DataSource="{Binding ReadingsY}">
					<vc:DataSeries.DataMappings>
						<vc:DataMapping MemberName="XValue" Path="Timestamp"></vc:DataMapping>
						<vc:DataMapping MemberName="YValue" Path="Reading"></vc:DataMapping>
					</vc:DataSeries.DataMappings>
				</vc:DataSeries>
				<vc:DataSeries ToolTipText="#AxisXLabel, Y = #YValue" RenderAs="Line" XValueType="DateTime" LegendText="Z" DataSource="{Binding ReadingsZ}">
					<vc:DataSeries.DataMappings>
						<vc:DataMapping MemberName="XValue" Path="Timestamp"></vc:DataMapping>
						<vc:DataMapping MemberName="YValue" Path="Reading"></vc:DataMapping>
					</vc:DataSeries.DataMappings>
				</vc:DataSeries>
			</vc:Chart.Series>
		</vc:Chart>
	</Grid>
</UserControl>